import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';
export namespace PerBusinessCelebrationsApi {
  /** 人员婚丧喜庆业务表信息 */
  export interface BusinessCelebrations {
    id: number; // 主键ID
    busiId?: string; // 业务主表ID
    celebrationsId: number; // 正式表ID，对应 per_celebrations.id，用于修改或删除时关联
    employeeId?: number; // 人员ID，对应 per_employee.id
    relation: string; // 与本人关系
    eventType: string; // 操办事项
    eventDate: string | Dayjs; // 办理时间
    eventLocation: string; // 办理地点
    participants: string; // 参加人数
    giftHandling: string; // 接受礼品及处理情况
    reportStatus: string; // 有否报告
    status: number; // 记录状态（1：有效，0：无效）
    remarks: string; // 备注
    changeType: string; // 变更类型（add：新增，update：修改，delete：删除）
    changeContent: string; // 变更内容(JSON格式，仅修改时记录差异)
    auditStatus: number; // 审核状态（0 草稿 1 审核中 2 审核完成）
    finalAuditStatus: number; // 最终审核状态（0 待审核 1 审核通过 2 审核不通过）
    auditTime: string | Dayjs; // 审核完成时间
    auditor: string; // 审核人
    auditComment: string; // 审核意见
    metadata: string; // 其他参数
  }
}

/** 查询人员婚丧喜庆业务表分页 */
export function getBusinessCelebrationsPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    PageResult<PerBusinessCelebrationsApi.BusinessCelebrations>
  >('/per/business-celebrations/page', data, { desensitize, encrypt });
}

/** 查询人员婚丧喜庆业务表详情 */
export function getBusinessCelebrations(params: { id: number }) {
  return requestClient.get<PerBusinessCelebrationsApi.BusinessCelebrations>(
    `/per/business-celebrations/get?id=${params.id}`,
  );
}

/** 新增人员婚丧喜庆业务表 */
export function createBusinessCelebrations(
  data: PerBusinessCelebrationsApi.BusinessCelebrations,
) {
  return requestClient.post('/per/business-celebrations/create', data);
}

/** 修改人员婚丧喜庆业务表 */
export function updateBusinessCelebrations(
  data: PerBusinessCelebrationsApi.BusinessCelebrations,
) {
  return requestClient.put('/per/business-celebrations/update', data);
}

/** 删除人员婚丧喜庆业务表 */
export function deleteBusinessCelebrations(params: { id: number }) {
  return requestClient.delete(
    `/per/business-celebrations/delete?id=${params.id}`,
  );
}

/** 批量删除人员婚丧喜庆业务表 */
export function deleteBusinessCelebrationsList(ids: number[]) {
  return requestClient.delete(
    `/per/business-celebrations/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出人员婚丧喜庆业务表 */
export function exportBusinessCelebrations(params: any) {
  return requestClient.download('/per/business-celebrations/export-excel', {
    params,
  });
}

/** 根据业务主表id去查询业务数据 */
export function getCelebrationsBusiId(data: any) {
  return requestClient.post<PerBusinessCelebrationsApi.BusinessCelebrations>(
    '/per/business-celebrations/getCelebrationsBusiId',
    data,
  );
}

/** 获取当前登录人婚丧喜庆情况 */
export function getCurrentCelebrations(
  data,
  desensitize: boolean,
  encrypt?: boolean,
) {
  return requestClient.post<
    List<PerBusinessCelebrationsApi.BusinessCelebrations>
  >('/per/business-celebrations/getCurrentCelebrations', data, {
    desensitize,
    encrypt,
  });
}
